home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / TextParam.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  4.9 KB  |  170 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.FilterInputStream;
  6. import java.io.IOException;
  7. import symjava.lang.Bignum;
  8. import symjava.sql.Date;
  9. import symjava.sql.SQLException;
  10. import symjava.sql.Time;
  11. import symjava.sql.Timestamp;
  12.  
  13. public class TextParam extends Field {
  14.    // $FF: renamed from: _s symantec.itools.db.net.NetString
  15.    NetString field_0;
  16.  
  17.    public TextParam(int id, String data) {
  18.       super._id = id;
  19.       super._type = 102;
  20.       if (data != null) {
  21.          this.field_0 = new NetString(data);
  22.       } else {
  23.          this.field_0 = new NetString("");
  24.       }
  25.    }
  26.  
  27.    public TextParam() {
  28.       super._id = 0;
  29.       super._type = 102;
  30.       this.field_0 = new NetString("");
  31.    }
  32.  
  33.    int getType() {
  34.       return 58;
  35.    }
  36.  
  37.    void read(DataInputStream in) throws SQLException, IOException, ErrorException {
  38.       in.readShort();
  39.       super._id = ((FilterInputStream)in).read();
  40.       super._type = 102;
  41.       ServerObject obj = (ServerObject)NetClass.getNextObject(in);
  42.       if (obj.getType() == 52) {
  43.          this.field_0 = (NetString)obj;
  44.       } else {
  45.          ((ServerObject)this).onObjectError(obj);
  46.       }
  47.    }
  48.  
  49.    void write(DataOutputStream out) throws IOException {
  50.       out.writeByte(this.getType());
  51.       out.writeShort(1);
  52.       out.writeByte(super._id);
  53.       this.field_0.write(out);
  54.    }
  55.  
  56.    public String getChar() throws SQLException {
  57.       return new String(this.field_0.getString());
  58.    }
  59.  
  60.    public String getVarChar() throws SQLException {
  61.       return new String(this.field_0.getString());
  62.    }
  63.  
  64.    public String getLongVarChar() throws SQLException {
  65.       return new String(this.field_0.getString());
  66.    }
  67.  
  68.    public boolean getBit() throws SQLException {
  69.       byte b = (byte)this.field_0.getString().charAt(0);
  70.       return b != 0;
  71.    }
  72.  
  73.    public byte getTinyInt() throws SQLException {
  74.       try {
  75.          Double d = new Double(this.field_0.getString());
  76.          return (byte)d.intValue();
  77.       } catch (Exception e) {
  78.          throw new SQLException(((Throwable)e).getMessage());
  79.       }
  80.    }
  81.  
  82.    public short getSmallInt() throws SQLException {
  83.       try {
  84.          Double d = new Double(this.field_0.getString());
  85.          return (short)d.intValue();
  86.       } catch (Exception e) {
  87.          throw new SQLException(((Throwable)e).getMessage());
  88.       }
  89.    }
  90.  
  91.    public int getInteger() throws SQLException {
  92.       try {
  93.          Double d = new Double(this.field_0.getString());
  94.          return d.intValue();
  95.       } catch (Exception e) {
  96.          throw new SQLException(((Throwable)e).getMessage());
  97.       }
  98.    }
  99.  
  100.    public long getBigInt() throws SQLException {
  101.       try {
  102.          Double d = new Double(this.field_0.getString());
  103.          return d.longValue();
  104.       } catch (Exception e) {
  105.          throw new SQLException(((Throwable)e).getMessage());
  106.       }
  107.    }
  108.  
  109.    public float getReal() throws SQLException {
  110.       return this.getFloat();
  111.    }
  112.  
  113.    public float getFloat() throws SQLException {
  114.       try {
  115.          Double d = new Double(this.field_0.getString());
  116.          return d.floatValue();
  117.       } catch (Exception e) {
  118.          throw new SQLException(((Throwable)e).getMessage());
  119.       }
  120.    }
  121.  
  122.    public double getDouble() throws SQLException {
  123.       try {
  124.          Double d = new Double(this.field_0.getString());
  125.          return d;
  126.       } catch (Exception e) {
  127.          throw new SQLException(((Throwable)e).getMessage());
  128.       }
  129.    }
  130.  
  131.    public Bignum getBignum(int scale) throws SQLException {
  132.       return new Bignum(this.field_0.getString(), scale);
  133.    }
  134.  
  135.    public Bignum getDecimal(int scale) throws SQLException {
  136.       return new Bignum(this.field_0.getString(), scale);
  137.    }
  138.  
  139.    public byte[] getBinary() throws SQLException {
  140.       try {
  141.          String s = this.field_0.getString();
  142.          byte[] dst = new byte[s.length()];
  143.          s.getBytes(0, s.length() - 1, dst, 0);
  144.          return dst;
  145.       } catch (Exception e) {
  146.          throw new SQLException(((Throwable)e).getMessage());
  147.       }
  148.    }
  149.  
  150.    public byte[] getVarBinary() throws SQLException {
  151.       return this.getBinary();
  152.    }
  153.  
  154.    public byte[] getLongVarBinary() throws SQLException {
  155.       return this.getBinary();
  156.    }
  157.  
  158.    public Date getDate() throws SQLException {
  159.       return Date.valueOf(this.field_0.getString());
  160.    }
  161.  
  162.    public Time getTime() throws SQLException {
  163.       return Time.valueOf(this.field_0.getString());
  164.    }
  165.  
  166.    public Timestamp getTimestamp() throws SQLException {
  167.       return Timestamp.valueOf(this.field_0.getString());
  168.    }
  169. }
  170.